/*
 * Base class for Vault and Archive operations
 * 
 * Distributed under Apache 2.0 license
 * Author: David Mail, email: david.mail37(at)gmail(dot)com
 * October 7 2012
 */

package com.pixamba.aws.glacier;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.glacier.AmazonGlacierClient;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 *
 * @author david
 */
public class AwsGlacier {
    protected AmazonGlacierClient client = null;
    protected AWSCredentials credentials = null;
    
    public AwsGlacier( String configFile) throws IOException {
        InputStream in = new FileInputStream( configFile);
        this.credentials = new PropertiesCredentials( in);
        
        in = new FileInputStream( configFile);
        Properties p = new Properties(); // create properties obj to get other params from the properties file, e.g. endPoint
        p.load( in);
        in.close();        
        
        this.client = new AmazonGlacierClient( this.credentials);
        this.client.setEndpoint( p.getProperty( "endPoint"));
    }
    
    public AmazonGlacierClient getClient(){
        return this.client;
    }
    
    public AWSCredentials getCredentials(){
        return this.credentials;
    }
    
}
